{* $Id$ *}
{include_core file="admin/lib/header.html" title="用户展示"}
  <div class="page-header border-bottom clearfix">
    <h2 class="left">用户管理<span>在这里对用户进行管理</span></h2>
    <a href="{AnUrl('user/admin/add')}" class="btn btn-success btn-sm right"><i class="icon-add"></i>添加用户</a>
  </div>
  <!--start:列表-->
  {foreach $data_list as $key => $info}
    <br>
    <table class="list-table" >
    <thead>
    <tr>
        <th class="txtleft" colspan="8" >{$info.table_info.TABLE_NAME} {$info.table_info.TABLE_COMMENT} </th>
    </tr>
    <tr>
      {if $status == 1}
      <th style="width:20px;"><input type="checkbox" class="selectAll"></th>
      {/if}
      <th style="width:10px;">编号</th>
      <th style="width:30px;">名字</th>
      <th style="width:20px;">类型</th>
      <th style="width:30px;">排序规则</th>
      <th style="width:10px;">是否为空</th>
      <th style="width:10px;">默认值</th>
      <th style="width:20px;">扩展</th>
      <th style="width:40px;">备注</th>
    </tr></thead>
    <tbody>
      {foreach $info.fields_list as $k=>$v}
        <tr id="dataList{$v.id}" {if $k%2 == 1} class="bg-gray"{/if} data-id="{$v.id}">
          <td style="width:10px;" class="js_userName">{$k + 1}</td>
          <td class="js_userName">{$v.COLUMN_NAME}</td>
          <td>{$v.COLUMN_TYPE}</td>
          <td>{$v.COLLATION_NAME}</td>
          <td>{$v.IS_NULLABLE}</td>
          <td>{$v.COLUMN_DEFAULT}</td>
          <td>{$v.EXTRA}</td>
          <td>{$v.COLUMN_COMMENT}</td>
        </tr>
      {foreachelse}
          <tr><td class="txtleft" colspan="8">暂无数据</td></tr>
      {/foreach}
    </tbody>
    {if $status == 1}
    <tfoot><tr><td><input type="checkbox" class="selectAll"></td><td colspan="6"><a href="{AnUrl("user/admin/delete")}" class="btn btn-danger btn-xs deleteAll">批量禁用</a></td></tr></tfoot>
    {/if}
  </table>
  {/foreach}

  <script type="text/javascript">
 
  $(function(){
      
      
      if ('{user_config::AGENCY}' == $('select[name="search_filter[role_id]"]').val()) {
          $('.js_assistant').show();
      } else {
          $('.js_assistant').hide();
          $('select[name="assistant_user_id"]').val('0');
      }
      
      $('select[name="search_filter[role_id]"]').change(function(){
          if ('{user_config::AGENCY}' == $(this).val()) {
              $('.js_assistant').show();
          } else {
              $('.js_assistant').hide();
              $('select[name="assistant_user_id"]').val('0');
          }
      });
      
      
   // 将制定的元素设置为可是区域居中
      function center_format(obj){
          // 获取可是窗口的宽度
          var winWidth  = $(window).width();
          var winHeight = $(window).height();
          
          // 计算窗体本身的宽和高
          var objWidth = obj.width();
          var objHeight = obj.height();
          
          // 设置窗体的位置
          obj.css('position', 'fixed');
          // 计算left和top值
          var objLeft = (winWidth - objWidth)/2;
          var objTop = (winHeight - objHeight)/3; // 如果除以2感觉不垂直居中
          obj.css('left', objLeft+'px');
          obj.css('top', objTop+'px');
          
      }
      
    // 高级搜索
    $('.js_advanced').click(function(e){
      e.preventDefault();
      var thisObj = $(this);
      var outBox  = thisObj.closest('form');
      if (thisObj.hasClass('js_isOpen')) {
        thisObj.removeClass('js_isOpen open');
        outBox.find('input').show();
        outBox.find('button').show();
        $('.js_advancedForm').hide();
      } else {
        thisObj.addClass('js_isOpen open');
        outBox.find('input').hide();
        outBox.find('button').hide();
        $('.js_advancedForm').show();
      }
    });
    
    // 查看子合伙人
    $('.js_showSecondDealer').click(function(){
        // 获取此一级合伙人的id
        var $url = $(this).attr('url');
        var th = $(this);
        // 发送ajax查询子合伙人
        $.ajax({
            url : $url,
            type : "get",
            dataType : 'json',
            error : function () {
              showMsg('此合伙人没有二级合伙人!');
            },
            success : function(res){
                if (res != 'no') {
                    var infoList = res;
                    $('.float-bg').show();
                    var list = $('.js_secondDealerList').clone(true, true);
                   	list.find('.js_dealerTitle').html(th.parents('tr').find('td.js_userName').html()+'的子合伙人信息');
                    $('body').append(list);

                    // 设置弹窗的位置
                    center_format(list);
                    list.show();
                    
                    // 说明 存在二级合伙人
					for (var i in infoList) {
					    var info = $('<tr><td style="width:200px;text-align:center;border:1px solid #ccc">'+infoList[i]["user_name"]+'</td><td style="width:200px;text-align:center;border:1px solid #ccc">'+infoList[i]["mobile"]+'</td></tr>');
					    list.find('.js_expressTable').append(info);
					}
                    
                    list.find('.js_closeDealerList').click(function(){
                        list.hide();
                        list.remove();
                        $('.float-bg').hide();
                    });
                    
                } else {
                    alert('此合伙人没有二级合伙人!');
                }
            }
        });
        
        return false;
    });
    
  });
  

  
  </script>
<div class="float-confirm js_secondDealerList" style="z-index: 20000;display: none; width:auto; height:auto; margin:0px; position : fixed;">
  <div class="float-confirm-con" style="margin:0px 0px;">
  	<a class="icon-close js_closeDealerList" href="javascript:void(0);">关闭</a>
    <p style="font-size:18px;color:#23a18b;" class="js_dealerTitle">子合伙人信息</p>
    <div style="width:auto;height:1px;background:#CCC;margin-bottom:20px;"></div>
    <div style="width:500px;max-height:400px;over-flow:hidden;margin-bottom:15px;">
      <table style="line-height:50px;border:1px solid #ccc;margin:0 auto;" class="js_expressTable">
        <tr>
          <th style="width:200px;text-align:center;border:1px solid #ccc">用户名</th>
          <th style="width:200px;text-align:center;border:1px solid #ccc">手机号码</th>
        </tr>
        
      </table>
      <table style="line-height:50px;display:none;width:400px;line-height:24px;" class="js_refundTable">
      </table>
    </div>
    <div style="width:auto;height:1px;background:#CCC;margin-bottom:20px;"></div>
  </div>
</div>
<div class="float-bg" style="z-index: 19999; display: none"></div>
  {include_core file="admin/lib/pager.html"}
<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
{include_core file="admin/lib/footer.html"}